<template>
    <header>这是parent页面</header>
    <main>
       <button @click="add">父组件+</button> 
        <Child :num="count" @handle="changeValue"></Child>
    </main>
</template>
<script lang="ts">
import { ref, reactive , toRefs, defineComponent } from 'vue'
import Child from './Child.vue'
export default defineComponent({
    name:"Parent",
    props:{},
    components:{
        Child
    },
    setup(){
        const state = reactive({
            count: 1
        })
        const add = (): void => {
            state.count += 1
        }
        const changeValue = (num: number) => {
            state.count += num
        }
        return{
            ...toRefs(state),
            add,
            changeValue
        }
    }
})
</script>